<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="./statics/layui/css/layui.css">
    <style>
        table {
            width: 500px !important;
            margin: 0 auto !important;/*居中*/
            /*目前选择器优先性较弱，1.可以给layui-table写新格式，谁离标签近似，谁先写谁生效 2.可以增加权重，加！important*/
        }
        p {
            text-align: center;
        }
        .layui-form-item {
            text-align: center;
        }
    </style>
</head>
<body>

<p>
    <form action="user?action=list" method="post">
    <div class="layui-form-item">
        <div class="layui-inline">
            <a class="layui-btn layui-bg-blue" href="addUser.jsp">新增用户</a>
            <div class="layui-input-inline layui-input-wrap">
               <input type="text" placeholder="请输入姓名" name="name" value="${condition.name}" class="layui-input">
            </div>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" placeholder="请输入密码" name="pass" value="${condition.pass}" class="layui-input">
            </div>
            <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">查询</button>
        </div>
    </div>
    </form>
<%--    <input type="text" name="name" placeholder="请输入姓名" autocomplete="off" class="layui-input">--%>
</p>
<%--<p> <a href="addUser.jsp">新增用户</a></p>--%>
<%--<p> 偶数行不同色</p>--%>
<table class="layui-table" lay-even>
    <colgroup>
        <col width="150">
        <col width="150">
        <col>
    </colgroup>
    <thead>
    <tr>
      <th>编号</th><%-- 列是th，行是td--%>
        <th>名字</th>
        <th>密码</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${users}" var="user">
        <tr>
            <td>${user.id}</td>
            <td>${user.name}</td>
            <td>${user.pass}</td>
            <td>
                <a href="user?action=toupdate&id=${user.id}">修改</a> <%--打开修改页面--%>
                <a href="user?action=delete&id=${user.id}">删除</a><%--并且传id，用&连接--%>
            </td>
        </tr>
    </c:forEach>
    <tr >
        <td colspan="4">
            <a href="user?action=list&currentPage=1">首页</a>
            <c:if test="${page.currentPage!=1}">
            <a href="user?action=list&currentPage=${page.currentPage-1}">上一页</a>
            </c:if>
            &nbsp;第${page.currentPage}页/总页数${page.totalPage}页&nbsp;
            <c:if test="${page.currentPage!=page.totalPage}">
            <a href="user?action=list&currentPage=${page.currentPage+1}">下一页</a>
            </c:if>
            <a href="user?action=list&currentPage=${page.totalPage}">末页</a>
        </td>
    </tr>
    </tbody>
</table>

</body>
</html>
